import pygame


class Info:
    def __init__(self, text, font_name, font_size, font_color, bg_color, coordinate):
        self.text = text
        self.font = pygame.font.Font(font_name, font_size)
        self.font_color = font_color
        self.bg_color = bg_color
        self.coordinate = coordinate
        self.text_rect = None
        # 创建字体对象
        self.text_surface = self.font.render(self.text, True, self.font_color, self.bg_color)

    def display(self):
        # 获取文本的表面尺寸，以便将其居中显示
        self.text_rect = self.text_surface.get_rect()
        # 居中
        self.text_rect.center = self.coordinate
        return self.text_rect

